package com.foruo.modules.demo.service;

import com.foruo.modules.demo.dao.DemoDao;
import com.foruo.modules.demo.entity.DemoEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * service层
 * @author GaoYuan
 * @date 2018/5/3 下午3:50
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class DemoService {

    @Autowired
    DemoDao demoDao;

    /**
     * 根据id获取demo详情
     * @author GaoYuan
     * @date 2018/5/3 下午3:52
     *
     * 读取数据 需要设置 readOnly = true
     * 增删改 需要设置 readOnly = false
     */
    @Transactional(readOnly = true,rollbackFor = Exception.class)
    public DemoEntity get(String id){
        return demoDao.get(id);
    }
}
